import request from '@/utils/request'

// 设备管理

// 搜索售货机(售货机列表)
export const searchDeviceList = (params) => {
  return request({
    url: '/api/vm-service/vm/search',
    params
  })
}

// 售货机类型列表(搜索)
export const searchDeviceType = (params) => {
  return request({
    url: '/api/vm-service/vmType/search',
    params
  })
}

// 新增售货机
export const addDeviceType = (data) => {
  return request({
    url: '/api/vm-service/vm',
    method: 'POST',
    data
  })
}

// 策略列表
export const getTactList = (params) => {
  return request({
    url: '/api/vm-service/policy',
    params
  })
}

// 查询售货机策略
export const poeTactList = (id) => {
  return request({
    url: `/api/vm-service/policy/vmPolicy/${id}`
  })
}

// 应用策略
export const applyPolicyApi = (data) => {
  return request({
    url: '/api/vm-service/vm/applyPolicy',
    method: 'PUT',
    data
  })
}

// 修改售货机点位
export const alterTactApi = ({ id, nodeId }) => {
  return request({
    url: `/api/vm-service/vm/${id}/${nodeId}`,
    method: 'PUT'
  })
}

// 取消策略
export const delPolicyApi = ({ innerCode, policyId }) => {
  return request({
    url: `/api/vm-service/vm/cancelPolicy/${innerCode}/${policyId}`,
    method: 'PUT'
  })
}

// 获取一定时间范围之内的订单总数
export const getrepltApi = (params) => {
  return request({
    url: `/api/order-service/report/orderCount`,
    params
  })
}

// 获取一定时间范围之内的收入
export const getMoneyApi = (params) => {
  return request({
    url: '/api/order-service/report/orderAmount',
    params
  })
}

// 获取售货机商品销量
export const getTactApi = ({ innerCode, start, end }) => {
  return request({
    url: `/api/order-service/report/skuCollect/${innerCode}/${start}/${end}`
  })
}

// 新增售货机类型
export const addvmtype = (data) => {
  return request({
    url: '/api/vm-service/vmType',
    method: 'POST',
    data
  })
}

// 修改售货机类型
export const alertvmtype = (data) => {
  return request({
    url: `/api/vm-service/vmType/${data.typeId}`,
    method: 'PUT',
    data
  })
}
